<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="myInput" onkeyup="method01()" ><span id="mySpan"></span>
</body>
<script>
  function method01(){
    let mySpan = document.getElementById("mySpan");
    let myInput = document.getElementById("myInput");
    let value = myInput.value;
    console.log(value);
    if (value.length<5){
        mySpan.innerHTML = "<font color='red'>用户名不合法</font>";
    }
    else {
        mySpan.innerHTML = "<font color='green'>用户名不合法</font>";
    }
  }
</script>
</html>